import "./style.css";

it("should compile", () => {
	const links = document.getElementsByTagName("link");
	const css = [];

	// Skip first because import it by default
	for (const link of links.slice(1)) {
		css.push(link.sheet.css);
	}

	expect(css).toMatchSnapshot();
	expect(Object.keys(__webpack_modules__).length).toBe(7);
	expect(__webpack_modules__['./index.js']).toBeDefined();
	expect(__webpack_modules__['./shared-external.png']).toBeDefined();
	expect(__webpack_modules__['./shared.png']).toBeDefined();
	expect(__webpack_modules__['%3D']).toBeDefined();
	expect(__webpack_modules__['']).toBeDefined();
	expect(__webpack_modules__['https://example.com/only-external.png']).toBeDefined();
	expect(__webpack_modules__['./style.css']).toBeDefined();

});

it("should work with shared asset module", () => {
	const img = new URL("./shared.png", import.meta.url);
	expect(img.href.endsWith("shared.png")).toBe(true);
});

it("should work with shared external asset module", () => {
	const img = new URL("./shared-external.png", import.meta.url);
	expect(img.href.endsWith("shared-external.png")).toBe(true);
});

it("should work with external asset module", () => {
	const img = new URL("https://example.com/only-external.png", import.meta.url);
	expect(img.href.endsWith("only-external.png")).toBe(true);
});

it("should work and extract DataURI", () => {
	const img = new URL("", import.meta.url);
	expect(img.href.endsWith(".svg")).toBe(true);
});

it("should work and extract shared DataURI", () => {
	const img = new URL("%3D", import.meta.url);
	expect(img.href.endsWith(".png")).toBe(true);
});
